import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router);

/* Layout */
import Layout from '@/layout'

export const constantRoutes = [

  { path: '/login', component: () => import('@/views/login/index'), hidden: true },
  { path: '/404', component: () => import('@/views/404'), hidden: true },
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    name: 'Dashboard',
    hidden: false,
    children: [{
      path: 'dashboard',
      name:"Dashboard",
      component: () => import('@/views/dashboard/surveyStatistics/index'),
      meta: { title: '首页', icon: 'dashboard' }
    }]
  },

  {
    path:"/registration",
    component:Layout,
    redirect:"/registration",
    name:"预约管理",
    hidden:false,
    meta: { title: '预约管理', icon: 'el-icon-date' },
    children:[
      {
        path:"/departmentList",
        name:"科室列表",
        component:()=>import("@/views/yy/departmentList"),
        meta:{title:"科室管理",icon:"department"}
      },
      {
        path:"doctorList",
        name:"医生列表",
        component:()=>import("@/views/yy/doctorList"),
        meta:{title:"医生管理",icon:"user"}
      },
      {
        path:"timeManagementList",
        name:"排班列表",
        component:()=>import("@/views/yy/timeManagementList"),
        meta:{title:"排班管理",icon:"timeManagement"}
      },
    ]
  },

  {
    path: '/act',
    component: Layout, //布局设置 不需要改变
    redirect: '/act',
    name: '报名管理',
    meta: { title: '报名管理', icon: 'example' },
    children: [
      {
        path: 'teacherList',
        name: '活动报名',
        component: () => import('@/views/act/actList'),
        meta: { title: '活动报名', icon: 'publishAct' }
      }
    ]
  },

  {
    path: '/hy',
    component: Layout,
    redirect: '/hy',
    name: '会员管理',
    meta: { title: '会员管理', icon: 'usercard' },
    children: [
      {
        path: '/hyList',
        name: '会员列表',
        component: () => import('@/views/hy/hyList'),
        meta: { title: '会员列表', icon: 'usercard' }
      },
    ]
  },

  {
    path: '/满意度调查管理',
    component: Layout,
    redirect: '/survey',
    children: [
      {
        path: 'index',
        name: 'Form',
        component: () => import('@/views/satisfactionSurvey/index'),
        meta: { title: '满意度调查管理', icon: 'satisfactionSurvey' }
      }
    ]
  },

  {
    path: '/recommend',
    component: Layout,
    redirect: '/nested/menu1',
    name: 'Nested',
    meta: {
      title: '推荐管理',
      icon: 'recommend'
    },
    children: [
      {
        path: '/recommendList',
        name: '推荐管理',
        component: () => import('@/views/recommend/index'),
        meta: { title: '推荐管理', icon: 'recommend' }
      }
    ]
  },
  // {
  //   path:"/wxPayTest",
  //   name:"支付",
  //   component:()=>import("@/views/wxPayTest/index"),
  //   meta:{title:"支付",icon:"recommend"}
  // },

  { path: '*', redirect: '/404',component: () => import('@/views/404'), hidden: true }
];

const createRouter = () => new Router({
  // mode: 'history', // require service support
  mode: 'history',
  scrollBehavior: () => ({y: 0}),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
